(no commit message)
authorasakurareiko@f3d908c71c009580228b264f63f21c7274df7476 <asakurareiko@web>
Sun, 25 Sep 2022 19:39:22 +0000 (19:39 +0000)
committeradmin <admin@branchable.com>
Sun, 25 Sep 2022 19:39:22 +0000 (19:39 +0000)
doc/todo/__91__PATCH__93___Run_freeze__47__thaw_hooks_on_crippled_fs.mdwn [new file with mode: 0644]

diff --git a/doc/todo/__91__PATCH__93___Run_freeze__47__thaw_hooks_on_crippled_fs.mdwn b/doc/todo/__91__PATCH__93___Run_freeze__47__thaw_hooks_on_crippled_fs.mdwn
new file mode 100644 (file)
index 0000000..22b1240
--- /dev/null
@@ -0,0 +1,74 @@
+This patch allows hooks to be run in WSL1 for a repo created on an NTFS volume but I think it also applies in general.
+
+```
+From d4587806d8fd1ea767a8effc06edc1a4e10f5bca Mon Sep 17 00:00:00 2001
+From: Reiko Asakura <asakurareiko@protonmail.ch>
+Date: Sun, 25 Sep 2022 15:21:24 -0400
+Subject: [PATCH] Run freeze and thaw hooks on crippled filesystems
+
+The user sets these hooks deliberately so they should always be run. For
+example this allows hooks to be used to manage file permissions on NTFS
+volumes in WSL1.
+---
+ Annex/Perms.hs | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/Annex/Perms.hs b/Annex/Perms.hs
+index 6681da7e0..69e344452 100644
+--- a/Annex/Perms.hs
++++ b/Annex/Perms.hs
+@@ -154,7 +154,7 @@ createWorkTreeDirectory dir = do
+  - that happens with write permissions.
+  -}
+ freezeContent :: RawFilePath -> Annex ()
+-freezeContent file = unlessM crippledFileSystem $
++freezeContent file =
+       withShared $ \sr -> freezeContent' sr file
+ freezeContent' :: SharedRepository -> RawFilePath -> Annex ()
+@@ -163,7 +163,7 @@ freezeContent' sr file = freezeContent'' sr file =<< getVersion
+ freezeContent'' :: SharedRepository -> RawFilePath -> Maybe RepoVersion -> Annex ()
+ freezeContent'' sr file rv = do
+       fastDebug "Annex.Perms" ("freezing content " ++ fromRawFilePath file)
+-      go sr
++      unlessM crippledFileSystem $ go sr
+       freezeHook file
+   where
+       go GroupShared = if versionNeedsWritableContentFiles rv
+@@ -253,7 +253,7 @@ thawContent' sr file = do
+  - permissions. -}
+ thawPerms :: Annex () -> Annex () -> Annex ()
+ thawPerms a hook = ifM crippledFileSystem
+-      ( void (tryNonAsync a)
++      ( hook >> void (tryNonAsync a)
+       , hook >> a
+       )
+@@ -263,9 +263,9 @@ thawPerms a hook = ifM crippledFileSystem
+  - file.
+  -}
+ freezeContentDir :: RawFilePath -> Annex ()
+-freezeContentDir file = unlessM crippledFileSystem $ do
++freezeContentDir file = do
+       fastDebug "Annex.Perms" ("freezing content directory " ++ fromRawFilePath dir)
+-      withShared go
++      unlessM crippledFileSystem $ withShared go
+       freezeHook dir
+   where
+       dir = parentDir file
+@@ -287,9 +287,9 @@ createContentDir dest = do
+       unlessM (liftIO $ R.doesPathExist dir) $
+               createAnnexDirectory dir 
+       -- might have already existed with restricted perms
+-      unlessM crippledFileSystem $ do
++      do
+               thawHook dir
+-              liftIO $ allowWrite dir
++              unlessM crippledFileSystem $ liftIO $ allowWrite dir
+   where
+       dir = parentDir dest
+-- 
+2.30.2
+
+```